home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / layout / nsFrameManager.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  10KB  |  240 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  * vim:cindent:ts=2:et:sw=2:
  3.  *
  4.  * ***** BEGIN LICENSE BLOCK *****
  5.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  6.  *
  7.  * The contents of this file are subject to the Mozilla Public License Version
  8.  * 1.1 (the "License"); you may not use this file except in compliance with
  9.  * the License. You may obtain a copy of the License at
  10.  * http://www.mozilla.org/MPL/
  11.  *
  12.  * Software distributed under the License is distributed on an "AS IS" basis,
  13.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  14.  * for the specific language governing rights and limitations under the
  15.  * License.
  16.  *
  17.  * The Original Code is mozilla.org code.
  18.  *
  19.  * The Initial Developer of the Original Code is
  20.  * Netscape Communications Corporation.
  21.  * Portions created by the Initial Developer are Copyright (C) 1998
  22.  * the Initial Developer. All Rights Reserved.
  23.  *
  24.  * Contributor(s):
  25.  *   Pierre Phaneuf <pp@ludusdesign.com>
  26.  *
  27.  * Alternatively, the contents of this file may be used under the terms of
  28.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  29.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  30.  * in which case the provisions of the GPL or the LGPL are applicable instead
  31.  * of those above. If you wish to allow use of your version of this file only
  32.  * under the terms of either the GPL or the LGPL, and not to allow others to
  33.  * use your version of this file under the terms of the MPL, indicate your
  34.  * decision by deleting the provisions above and replace them with the notice
  35.  * and other provisions required by the GPL or the LGPL. If you do not delete
  36.  * the provisions above, a recipient may use your version of this file under
  37.  * the terms of any one of the MPL, the GPL or the LGPL.
  38.  *
  39.  * ***** END LICENSE BLOCK *****
  40.  *
  41.  * This Original Code has been modified by IBM Corporation. Modifications made
  42.  * by IBM described herein are Copyright (c) International Business Machines
  43.  * Corporation, 2000. Modifications to Mozilla code or documentation identified
  44.  * per MPL Section 3.3
  45.  *
  46.  * Date             Modified by     Description of modification
  47.  * 04/20/2000       IBM Corp.      OS/2 VisualAge build.
  48.  */
  49.  
  50. #ifndef _nsFrameManager_h_
  51. #define _nsFrameManager_h_
  52.  
  53. #include "nsIFrame.h"
  54. #include "nsIStatefulFrame.h"
  55. #include "nsChangeHint.h"
  56. #include "nsFrameManagerBase.h"
  57.  
  58. /**
  59.  * Frame manager interface. The frame manager serves two purposes:
  60.  * <li>provides a service for mapping from content to frame and from
  61.  * out-of-flow frame to placeholder frame.
  62.  * <li>handles structural modifications to the frame model. If the frame model
  63.  * lock can be acquired, then the changes are processed immediately; otherwise,
  64.  * they're queued and processed later.
  65.  *
  66.  * Do not add virtual methods to this class, or bryner will punish you.
  67.  */
  68.  
  69. class nsFrameManager : public nsFrameManagerBase
  70. {
  71. public:
  72.   nsFrameManager() NS_HIDDEN;
  73.   ~nsFrameManager() NS_HIDDEN;
  74.  
  75.   void* operator new(size_t aSize, nsIPresShell* aHost) {
  76.     NS_ASSERTION(aSize == sizeof(nsFrameManager), "Unexpected subclass");
  77.     NS_ASSERTION(aSize == sizeof(nsFrameManagerBase),
  78.                  "Superclass/subclass mismatch");
  79.     return aHost->FrameManager();
  80.   }
  81.  
  82.   // Initialization
  83.   NS_HIDDEN_(nsresult) Init(nsIPresShell* aPresShell, nsStyleSet* aStyleSet);
  84.  
  85.   /*
  86.    * After Destroy is called, it is an error to call any FrameManager methods.
  87.    * Destroy should be called when the frame tree managed by the frame
  88.    * manager is no longer being displayed.
  89.    */
  90.   NS_HIDDEN_(void) Destroy();
  91.  
  92.   /*
  93.    * Gets and sets the root frame (typically the viewport). The lifetime of the
  94.    * root frame is controlled by the frame manager. When the frame manager is
  95.    * destroyed, it destroys the entire frame hierarchy.
  96.    */
  97.   NS_HIDDEN_(nsIFrame*) GetRootFrame() { return mRootFrame; }
  98.   NS_HIDDEN_(void)      SetRootFrame(nsIFrame* aRootFrame)
  99.   {
  100.     NS_ASSERTION(!mRootFrame, "already have a root frame");
  101.     mRootFrame = aRootFrame;
  102.   }
  103.  
  104.   /*
  105.    * Get the canvas frame, searching from the root frame down.
  106.    * The canvas frame may or may not exist, so this may return null.
  107.    */
  108.   NS_HIDDEN_(nsIFrame*) GetCanvasFrame();
  109.  
  110.   // Primary frame functions
  111.   NS_HIDDEN_(nsIFrame*) GetPrimaryFrameFor(nsIContent* aContent);
  112.   NS_HIDDEN_(nsresult)  SetPrimaryFrameFor(nsIContent* aContent,
  113.                                            nsIFrame* aPrimaryFrame);
  114.   NS_HIDDEN_(void)      ClearPrimaryFrameMap();
  115.  
  116.   // Placeholder frame functions
  117.   NS_HIDDEN_(nsPlaceholderFrame*) GetPlaceholderFrameFor(nsIFrame* aFrame);
  118.   NS_HIDDEN_(nsresult)
  119.     RegisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame);
  120.  
  121.   NS_HIDDEN_(void)
  122.     UnregisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame);
  123.  
  124.   NS_HIDDEN_(void)      ClearPlaceholderFrameMap();
  125.  
  126.   // Mapping undisplayed content
  127.   NS_HIDDEN_(nsStyleContext*) GetUndisplayedContent(nsIContent* aContent);
  128.   NS_HIDDEN_(void) SetUndisplayedContent(nsIContent* aContent,
  129.                                          nsStyleContext* aStyleContext);
  130.   NS_HIDDEN_(void) ChangeUndisplayedContent(nsIContent* aContent,
  131.                                             nsStyleContext* aStyleContext);
  132.   NS_HIDDEN_(void) ClearUndisplayedContentIn(nsIContent* aContent,
  133.                                              nsIContent* aParentContent);
  134.   NS_HIDDEN_(void) ClearAllUndisplayedContentIn(nsIContent* aParentContent);
  135.   NS_HIDDEN_(void) ClearUndisplayedContentMap();
  136.  
  137.   // Functions for manipulating the frame model
  138.   NS_HIDDEN_(nsresult) AppendFrames(nsIFrame*       aParentFrame,
  139.                                     nsIAtom*        aListName,
  140.                                     nsIFrame*       aFrameList)
  141.   {
  142.     return aParentFrame->AppendFrames(aListName, aFrameList);
  143.   }
  144.  
  145.   NS_HIDDEN_(nsresult) InsertFrames(nsIFrame*       aParentFrame,
  146.                                     nsIAtom*        aListName,
  147.                                     nsIFrame*       aPrevFrame,
  148.                                     nsIFrame*       aFrameList);
  149.  
  150.   NS_HIDDEN_(nsresult) RemoveFrame(nsIFrame*       aParentFrame,
  151.                                    nsIAtom*        aListName,
  152.                                    nsIFrame*       aOldFrame);
  153.  
  154.   NS_HIDDEN_(nsresult) ReplaceFrame(nsIFrame*       aParentFrame,
  155.                                     nsIAtom*        aListName,
  156.                                     nsIFrame*       aOldFrame,
  157.                                     nsIFrame*       aNewFrame)
  158.   {
  159.     return aParentFrame->ReplaceFrame(aListName, aOldFrame, aNewFrame);
  160.   }
  161.  
  162.   /*
  163.    * Notification that a frame is about to be destroyed. This allows any
  164.    * outstanding references to the frame to be cleaned up.
  165.    */
  166.   NS_HIDDEN_(void)     NotifyDestroyingFrame(nsIFrame* aFrame);
  167.  
  168.   /*
  169.    * Reparent the style contexts of this frame subtree to live under the new
  170.    * given parent style context.  The StyleContextParent of aFrame should be
  171.    * changed _before_ this method is called, so that style tree verification
  172.    * can take place correctly.
  173.    */
  174.   NS_HIDDEN_(nsresult) ReParentStyleContext(nsIFrame* aFrame, 
  175.                                             nsStyleContext* aNewParentContext);
  176.  
  177.   /*
  178.    * Re-resolve the style contexts for a frame tree.  Returns the top-level
  179.    * change hint resulting from the style re-resolution.
  180.    */
  181.   NS_HIDDEN_(nsChangeHint)
  182.     ComputeStyleChangeFor(nsIFrame* aFrame,
  183.                           nsStyleChangeList* aChangeList,
  184.                           nsChangeHint aMinChange);
  185.  
  186.   // Determine whether an attribute affects style
  187.   NS_HIDDEN_(nsReStyleHint) HasAttributeDependentStyle(nsIContent *aContent,
  188.                                                        nsIAtom *aAttribute,
  189.                                                        PRInt32 aModType);
  190.  
  191.   /*
  192.    * Capture/restore frame state for the frame subtree rooted at aFrame.
  193.    * aState is the document state storage object onto which each frame
  194.    * stores its state.
  195.    */
  196.  
  197.   NS_HIDDEN_(void) CaptureFrameState(nsIFrame*              aFrame,
  198.                                      nsILayoutHistoryState* aState);
  199.  
  200.   NS_HIDDEN_(void) RestoreFrameState(nsIFrame*              aFrame,
  201.                                      nsILayoutHistoryState* aState);
  202.  
  203.   /*
  204.    * Add/restore state for one frame
  205.    * (special, global type, like scroll position)
  206.    */
  207.   NS_HIDDEN_(void) CaptureFrameStateFor(nsIFrame*              aFrame,
  208.                                         nsILayoutHistoryState* aState,
  209.                                         nsIStatefulFrame::SpecialStateID aID =
  210.                                                       nsIStatefulFrame::eNoID);
  211.  
  212.   NS_HIDDEN_(void) RestoreFrameStateFor(nsIFrame*              aFrame,
  213.                                         nsILayoutHistoryState* aState,
  214.                                         nsIStatefulFrame::SpecialStateID aID =
  215.                                                       nsIStatefulFrame::eNoID);
  216.  
  217. #ifdef NS_DEBUG
  218.   /**
  219.    * DEBUG ONLY method to verify integrity of style tree versus frame tree
  220.    */
  221.   NS_HIDDEN_(void) DebugVerifyStyleTree(nsIFrame* aFrame);
  222. #endif
  223.  
  224. private:
  225.  
  226.   NS_HIDDEN_(nsIPresShell*) GetPresShell() const { return mPresShell; }
  227.   NS_HIDDEN_(nsPresContext*) GetPresContext() const {
  228.     return mPresShell->GetPresContext();
  229.   }
  230.  
  231.   NS_HIDDEN_(nsChangeHint)
  232.     ReResolveStyleContext(nsPresContext    *aPresContext,
  233.                           nsIFrame          *aFrame,
  234.                           nsIContent        *aParentContent,
  235.                           nsStyleChangeList *aChangeList, 
  236.                           nsChangeHint       aMinChange);
  237. };
  238.  
  239. #endif
  240.